package com.atguigu04._throw;

public class throwtest {
    public static void main(String[] args) {
        Student s=new Student();
        try {
            s.re(-10);
        }catch (Exception e){
            e.printStackTrace();
        }

    }
}

class Student{
    int id;
    public void re(int id)throws Exception{
        if(id>0){
            this.id=id;
        }else{
            //手动抛出异常
           // throw new Exception("非法");
        }
    }
}
